#include "view_others.h"
#include "display_ctrl.h"
#include "platform_assert.h"
#include "lfs_file_manager_auto.h"
#include "rtc.h"
#include "datetime.h"
#include "blecom.h"
#include "battery_ctrl.h"
#include "sport_his.h"
#include "display_interface_240x240.h"
#include "datetime.h"
#include "heart_rate_interface.h"
#include "font/num_font.h"
#include "view_others_device_info.h"
#include "view_common.h"
#include "view_others_stopwatch.h"
#include "Motor.h"
#include "view.h"
#include "times/view_time_0.h"
#include "sports_mode.h"
#include "app_trace.h"
#include "device_type.h"
#include "localize.h"
#define LOG(fmt, ...) app_trace_log(fmt "\r\n", ##__VA_ARGS__)
#if defined(NO_APP_URL_UI)
#else
void view_others_app_url_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.com_data.i_temp[0] = get_device_type();
        disp_ctrl.auto_refresh_time = 1000;
    }
#ifdef IT_POWER_01_UI
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 34, 34, FILE_IMG_sb_sj_ewm_34_34);
#else
    if (disp_ctrl.com_data.i_temp[0] == device_type_read)
    {
        _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 55, 43, FILE_IMG_Read_DownloadUrl_55_43);
    }
    else
    {
#ifdef STORE_APP_URL
        _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 55, 43, FILE_IMG_to_hard_store);
#else
        _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 55, 43, FILE_IMG_9409_hard);
#endif
    }
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_AppDownload, 50);

#endif
}
#endif
void view_others_back_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 300;
        datetime_t UIdatetime = DateSync();
        disp_ctrl.com_data.i_temp[3] = UIdatetime.time.hour;
        if (if_time_hour_system_12())
        {
            disp_ctrl.com_data.i_temp[3] %= 12;
            if (disp_ctrl.com_data.i_temp[3] == 0)
            {
                disp_ctrl.com_data.i_temp[3] = 12;
            }
        }
        disp_ctrl.com_data.i_temp[4] = UIdatetime.time.minute;
        disp_ctrl.com_data.i_temp[8] = battery_ctrl_if_charging();
        disp_ctrl.com_data.i_temp[9] = battery_ctrl_get_percent();
        disp_ctrl.com_data.i_temp[5] = ble_if_connected();
    }
    if (disp_ctrl.com_data.i_temp[5])
    {
        disp_draw_user_image(42, 3, img_ble_connect);
    }
    else
    {
        disp_draw_user_image(42, 0, img_ble_disconnect);
    }
    show_common_time(disp_ctrl.com_data.i_temp[3], disp_ctrl.com_data.i_temp[4]);
    show_time_0_battery(disp_ctrl.com_data.i_temp[9], disp_ctrl.com_data.i_temp[8]);

    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 53, 30, FILE_IMG_E103_back_53_30);
    // _disp_show_flash_img(DISP_LFS_FILE_INDEX_1, 93, 188, FILE_IMG_E106_back_text_93_188);
    // disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_Back, FILE_IMG_localize_en_Back_93_188, 93, 188, 50);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_Back, 50);
}

void view_others_base_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 500;
        datetime_t UIdatetime = DateSync();
        disp_ctrl.com_data.i_temp[3] = UIdatetime.time.hour;
        if (if_time_hour_system_12())
        {
            disp_ctrl.com_data.i_temp[3] %= 12;
            if (disp_ctrl.com_data.i_temp[3] == 0)
            {
                disp_ctrl.com_data.i_temp[3] = 12;
            }
        }
        disp_ctrl.com_data.i_temp[4] = UIdatetime.time.minute;
        disp_ctrl.com_data.i_temp[8] = battery_ctrl_if_charging();
        disp_ctrl.com_data.i_temp[9] = battery_ctrl_get_percent();
        disp_ctrl.com_data.i_temp[5] = ble_if_connected();
    }
    if (disp_ctrl.com_data.i_temp[5])
    {
        disp_draw_user_image(42, 3, img_ble_connect);
    }
    else
    {
        disp_draw_user_image(42, 0, img_ble_disconnect);
    }
    show_common_time(disp_ctrl.com_data.i_temp[3], disp_ctrl.com_data.i_temp[4]);
    show_time_0_battery(disp_ctrl.com_data.i_temp[9], disp_ctrl.com_data.i_temp[8]);
    // _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 87, 198, FILE_IMG_E304_other_text_87_198);
    // disp_show_localize(DISP_LFS_FILE_INDEX_0, localize_string_key_Other, FILE_IMG_localize_en_Other_87_198, 87, 198, 50);
    disp_show_localize(DISP_LFS_FILE_INDEX_0, localize_string_key_Other, 50);

#if defined(Z2_BOARD) || defined(BT100_BOARD)
#if defined(SW07_PROJECT)
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_1, 48, 24, FILE_IMG_liui);
#else
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_1, 47, 24, FILE_IMG_1002_other_47_24);
#endif
#else
    img_gif_com_t const img_cfg_2 = {
        .gif_count = 3,
        .img[0].x = 45,
        .img[0].y = 17,
        .img[0].sn = FILE_IMG_E301_other_1_45_17,
        .img[1].x = 45,
        .img[1].y = 17,
        .img[1].sn = FILE_IMG_E302_other_2_45_17,
        .img[2].x = 45,
        .img[2].y = 17,
        .img[2].sn = FILE_IMG_E303_other_3_45_17,
    };
    _disp_show_flash_img_gif_all(&img_cfg_2, DISP_LFS_FILE_INDEX_1);
#endif
}
void view_others_camera_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 300;
        datetime_t UIdatetime = DateSync();
        disp_ctrl.com_data.i_temp[3] = UIdatetime.time.hour;
        if (if_time_hour_system_12())
        {
            disp_ctrl.com_data.i_temp[3] %= 12;
            if (disp_ctrl.com_data.i_temp[3] == 0)
            {
                disp_ctrl.com_data.i_temp[3] = 12;
            }
        }
        disp_ctrl.com_data.i_temp[4] = UIdatetime.time.minute;
        disp_ctrl.com_data.i_temp[8] = battery_ctrl_if_charging();
        disp_ctrl.com_data.i_temp[9] = battery_ctrl_get_percent();
        disp_ctrl.com_data.i_temp[5] = ble_if_connected();
    }
    if (disp_ctrl.com_data.i_temp[5])
    {
        disp_draw_user_image(42, 3, img_ble_connect);
    }
    else
    {
        disp_draw_user_image(42, 0, img_ble_disconnect);
    }
    show_common_time(disp_ctrl.com_data.i_temp[3], disp_ctrl.com_data.i_temp[4]);
    show_time_0_battery(disp_ctrl.com_data.i_temp[9], disp_ctrl.com_data.i_temp[8]);
#if defined(Z2_BOARD) || defined(BT100_BOARD)
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 47, 24, FILE_IMG_1201_camera_47_24);
#else
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 53, 30, FILE_IMG_E101_camera_53_30);
#endif
    // _disp_show_flash_img(DISP_LFS_FILE_INDEX_1, 79, 188, FILE_IMG_E104_camera_text_79_188);
    // disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_Camera, FILE_IMG_localize_en_Camera_79_188, 79, 188, 50);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_Camera, 50);
}

void view_others_camera_shake_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        bool connect = ble_if_connected();
        disp_ctrl.com_data.i_temp[1] = battery_ctrl_get_level(battery_ctrl_get_percent());
        disp_ctrl.com_data.i_temp[2] = battery_ctrl_if_charging();
        disp_ctrl.auto_refresh_time = 500;
        disp_ctrl.auto_close_delay = 1000;
        if (!connect && disp_ctrl.com_data.i_temp[0] != connect)
        {
            motor_start(100);
            disp_ctrl.auto_refresh_count = 0;
            disp_ctrl.auto_refresh_time = 0;
        }
        disp_ctrl.com_data.i_temp[0] = connect;
        if (connect)
        {
            display_set_update_area(44, 52, 51 + 140, 52 + 110);
        }
        else
        {
            disp_ctrl.area_update_flag = 0;
        }
        datetime_t UIdatetime = DateSync();
        disp_ctrl.com_data.i_temp[3] = UIdatetime.time.hour;
        if (if_time_hour_system_12())
        {
            disp_ctrl.com_data.i_temp[3] %= 12;
            if (disp_ctrl.com_data.i_temp[3] == 0)
            {
                disp_ctrl.com_data.i_temp[3] = 12;
            }
        }
        disp_ctrl.com_data.i_temp[4] = UIdatetime.time.minute;
        disp_ctrl.com_data.i_temp[8] = battery_ctrl_if_charging();
        disp_ctrl.com_data.i_temp[9] = battery_ctrl_get_percent();
    }
    show_common_time(disp_ctrl.com_data.i_temp[3], disp_ctrl.com_data.i_temp[4]);
    show_time_0_battery(disp_ctrl.com_data.i_temp[9], disp_ctrl.com_data.i_temp[8]);
    if (!disp_ctrl.com_data.i_temp[0])
    {
        if (disp_ctrl.auto_refresh_count > 6)
        {
            display_show(view_others_camera, DISP_MODE_NORMAL);
            return;
        }
#if defined(Z2_BOARD) || defined(BT100_BOARD)
        _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 57, 31, FILE_IMG_1306_nocon_57_31);
#else
        _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 73, 41, FILE_IMG_J103_notconnected_73_41);
#endif

        // disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_AlertNotConnected, FILE_IMG_localize_en_AlertNotConnected_49_183, 49, 183, 50);
        disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_AlertNotConnected, 50);
        return;
    }
    const img_gif_com_t img_cfg = {
        .gif_count = 2,
        .img[0].x = 44,
        .img[0].y = 52,
        .img[0].sn = FILE_IMG_E401_camera_1_44_52,
        .img[1].x = 51,
        .img[1].y = 52,
        .img[1].sn = FILE_IMG_E402_camera_2_51_52,
    };
    _disp_show_flash_img_gif_all(&img_cfg, DISP_LFS_FILE_INDEX_0);
    // _disp_show_flash_img(DISP_LFS_FILE_INDEX_1, 32, 188, FILE_IMG_E404_camer_text_32_188);
    // disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_Shake, FILE_IMG_localize_en_Shake_32_188, 32, 188, 50);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_Shake, 50);

    if (disp_ctrl.auto_refresh_count > 4)
    {
        display_show(view_others_camera_static, DISP_MODE_NORMAL);
    }
    if (disp_ctrl.com_data.i_temp[6])
    {
        disp_draw_user_image(42, 3, img_ble_connect);
    }
    else
    {
        disp_draw_user_image(42, 0, img_ble_disconnect);
    }
}
void view_others_camera_static_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        bool connect = ble_if_connected();
        disp_ctrl.com_data.i_temp[1] = battery_ctrl_get_level(battery_ctrl_get_percent());
        disp_ctrl.com_data.i_temp[2] = battery_ctrl_if_charging();
        disp_ctrl.auto_refresh_time = 1000;
        disp_ctrl.auto_close_delay = 2000;
        if (!connect && disp_ctrl.com_data.i_temp[0] != connect)
        {
            motor_start(100);
            disp_ctrl.auto_refresh_count = 0;
        }
        disp_ctrl.com_data.i_temp[0] = connect;
        if (disp_ctrl.auto_refresh_count > 5)
        {
            display_show(view_others_camera, DISP_MODE_NORMAL);
            return;
        }
        datetime_t UIdatetime = DateSync();
        disp_ctrl.com_data.i_temp[3] = UIdatetime.time.hour;
        if (if_time_hour_system_12())
        {
            disp_ctrl.com_data.i_temp[3] %= 12;
            if (disp_ctrl.com_data.i_temp[3] == 0)
            {
                disp_ctrl.com_data.i_temp[3] = 12;
            }
        }
        disp_ctrl.com_data.i_temp[4] = UIdatetime.time.minute;
        disp_ctrl.com_data.i_temp[8] = battery_ctrl_if_charging();
        disp_ctrl.com_data.i_temp[9] = battery_ctrl_get_percent();
        disp_ctrl.com_data.i_temp[6] = ble_if_connected();
    }
    show_common_time(disp_ctrl.com_data.i_temp[3], disp_ctrl.com_data.i_temp[4]);
    show_time_0_battery(disp_ctrl.com_data.i_temp[9], disp_ctrl.com_data.i_temp[8]);
    if (!disp_ctrl.com_data.i_temp[0])
    {
        if (disp_ctrl.auto_refresh_count > 3)
        {
            display_show(view_others_camera, DISP_MODE_NORMAL);
            return;
        }
#if defined(Z2_BOARD) || defined(BT100_BOARD)
        _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 57, 31, FILE_IMG_1306_nocon_57_31);
#else
        _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 73, 41, FILE_IMG_J103_notconnected_73_41);
#endif

        // _disp_show_flash_img(DISP_LFS_FILE_INDEX_1, 49, 183, FILE_IMG_J104_notconnected_text_49_183);
        // disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_AlertNotConnected, FILE_IMG_localize_en_AlertNotConnected_49_183, 49, 183, 50);
        disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_AlertNotConnected, 50);
        return;
    }
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 44, 52, FILE_IMG_E401_camera_1_44_52);
    // _disp_show_flash_img(DISP_LFS_FILE_INDEX_1, 32, 188, FILE_IMG_E404_camer_text_32_188);
    // disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_Shake, FILE_IMG_localize_en_Shake_32_188, 32, 188, 50);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_Shake, 50);

    if (disp_ctrl.com_data.i_temp[6])
    {
        disp_draw_user_image(42, 3, img_ble_connect);
    }
    else
    {
        disp_draw_user_image(42, 0, img_ble_disconnect);
    }
}

void view_others_power_off_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 300;
        datetime_t UIdatetime = DateSync();
        disp_ctrl.com_data.i_temp[3] = UIdatetime.time.hour;
        if (if_time_hour_system_12())
        {
            disp_ctrl.com_data.i_temp[3] %= 12;
            if (disp_ctrl.com_data.i_temp[3] == 0)
            {
                disp_ctrl.com_data.i_temp[3] = 12;
            }
        }
        disp_ctrl.com_data.i_temp[4] = UIdatetime.time.minute;
        disp_ctrl.com_data.i_temp[8] = battery_ctrl_if_charging();
        disp_ctrl.com_data.i_temp[9] = battery_ctrl_get_percent();
        disp_ctrl.com_data.i_temp[5] = ble_if_connected();
    }
    if (disp_ctrl.com_data.i_temp[5])
    {
        disp_draw_user_image(42, 3, img_ble_connect);
    }
    else
    {
        disp_draw_user_image(42, 0, img_ble_disconnect);
    }
    show_common_time(disp_ctrl.com_data.i_temp[3], disp_ctrl.com_data.i_temp[4]);
    show_time_0_battery(disp_ctrl.com_data.i_temp[9], disp_ctrl.com_data.i_temp[8]);

#if defined(Z2_BOARD) || defined(BT100_BOARD)
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 47, 24, FILE_IMG_1202_shutdown_47_24);
#else
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 53, 30, FILE_IMG_E102_poweroff_53_30);
#endif

    // _disp_show_flash_img(DISP_LFS_FILE_INDEX_1, 66, 188, FILE_IMG_E105_poweroff_text_66_188);
    // disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_PowerOff, FILE_IMG_localize_en_PowerOff_66_188, 66, 188, 50);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_PowerOff, 50);
}

view_event_result_t view_others_camera_event(event_param_t const *param)
{
    switch (param->event)
    {
#ifdef EVENT_LEVEL_DOWN
    case event_move_level_down:
#endif
#ifdef EVENT_BUTTON_FRONT
    case event_button_front_long_press:
#endif
#ifdef USE_TOUCHPAD
    case BUTTON_EVENT_TP_TAP_LONG:
#endif
        if (ble_if_connected())
        {
            display_show(view_prompt_camera_ready, DISP_MODE_NORMAL);
            BraceletSendToAPPCamera(CAMERA_CMD_SLAVE_INTOCAMERA);
        }
        else
        {
            display_show(view_prompt_not_connect, DISP_MODE_NORMAL);
        }
        return view_event_result_handled;
#ifdef EVENT_PREVIOUS_VIEW
    case event_move_previous_view:
        display_show(view_others_back - VIEW_LEVEL_1_SUB_COUNT, DISP_MODE_UP_MOVE);
        return view_event_result_handled;
#endif
    }
    return view_event_result_not_handled;
}
view_event_result_t view_others_camera_static_event(event_param_t const *param)
{
    switch (param->event)
    {
#ifdef EVENT_PREVIOUS_VIEW
    case event_move_previous_view:
#endif
#ifdef EVENT_NEXT_VIEW
    case event_move_next_view:
#endif
#ifdef EVENT_LEVEL_DOWN
    case event_move_level_down:
#endif
#ifdef EVENT_BUTTON_FRONT
    case event_button_front_press:
#endif
        return view_event_result_handled;
#ifdef EVENT_BUTTON_FRONT
    case event_button_front_long_press:
        display_show(DISP_TYPE_CAMERA, DISP_MODE_NORMAL);
        return view_event_result_handled;
#endif
    case event_view_exit:
        if (param->next_view != view_others_camera_shake)
        {
            BraceletSendToAPPCamera(CAMERA_CMD_SLAVE_LEVECAMERA);
            sports_mode_state_t state = (sports_mode_state_t)sports_mode_get_state();
            switch (state)
            {
            // case sports_mode_state_pause:
            //     display_show(view_sports_paused, DISP_MODE_NORMAL);
            //     return view_event_result_handled;
            case sports_mode_state_normal:
                display_show(view_sports_state_0, DISP_MODE_NORMAL);
                return view_event_result_handled;
            }
        }
        return view_event_result_handled;
    case event_shake:
        if (ble_if_connected())
        {
            BraceletSendToAPPCamera(CAMERA_CMD_SLAVE_STARTPHOTO);
            motor_start_extend(MOTOR_VIBRATE_TYPE_SHARK);
            display_show(view_others_camera_shake, DISP_MODE_NORMAL);
        }
        return view_event_result_handled;
    }
    return view_event_result_not_handled;
}
view_event_result_t view_others_camera_shake_event(event_param_t const *param)
{
    switch (param->event)
    {
#ifdef EVENT_PREVIOUS_VIEW
    case event_move_previous_view:
#endif
#ifdef EVENT_NEXT_VIEW
    case event_move_next_view:
#endif
#ifdef EVENT_LEVEL_DOWN
    case event_move_level_down:
#endif
#ifdef EVENT_BUTTON_FRONT
    case event_button_front_press:
#endif
        return view_event_result_handled;
#ifdef EVENT_BUTTON_FRONT
    case event_button_front_long_press:
        display_show(DISP_TYPE_CAMERA, DISP_MODE_NORMAL);
        return view_event_result_handled;
#endif
    case event_view_exit:
        if (param->next_view != view_others_camera_static)
        {
            BraceletSendToAPPCamera(CAMERA_CMD_SLAVE_LEVECAMERA);
            sports_mode_state_t state = (sports_mode_state_t)sports_mode_get_state();
            switch (state)
            {
            // case sports_mode_state_pause:
            //     display_show(view_sports_paused, DISP_MODE_NORMAL);
            //     return view_event_result_handled;
            case sports_mode_state_normal:
                display_show(view_sports_state_0, DISP_MODE_NORMAL);
                return view_event_result_handled;
            }
        }
        return view_event_result_handled;
    case event_shake:
        disp_ctrl.auto_refresh_count = 0;
        if (ble_if_connected())
        {
            BraceletSendToAPPCamera(CAMERA_CMD_SLAVE_STARTPHOTO);
            motor_start_extend(MOTOR_VIBRATE_TYPE_SHARK);
        }
        return view_event_result_handled;
    }
    return view_event_result_not_handled;
}
view_event_result_t view_others_device_info_detail_event(event_param_t const *param)
{
    switch (param->event)
    {
#ifdef EVENT_PREVIOUS_VIEW
    case event_move_previous_view:
#endif
#ifdef EVENT_NEXT_VIEW
    case event_move_next_view:
#endif
#ifdef EVENT_LEVEL_DOWN
    case event_move_level_down:
#endif
#ifdef EVENT_BUTTON_FRONT
    case event_button_front_press:
#endif
        return view_event_result_handled;
#ifdef EVENT_BUTTON_FRONT
    case event_button_front_long_press:
#endif
#ifdef USE_TOUCHPAD
    case BUTTON_EVENT_TP_TAP_LONG:
#endif
#ifdef EVENT_LEVEL_UP
    case event_move_level_up:
#endif
        display_show(view_others_device_info, DISP_MODE_NORMAL);
        return view_event_result_handled;
    case event_view_entry:
        disp_ctrl.auto_close_delay = 10000;
        return view_event_result_handled;
    case event_view_re_screen_on:
        disp_ctrl.auto_close_delay = 10000;
        return view_event_result_handled;
    }
    return view_event_result_not_handled;
}
#if defined(UMG01_PROJECT)
#else
view_event_result_t view_others_app_url_event(event_param_t const *param)
{
    switch (param->event)
    {
#ifdef EVENT_LEVEL_DOWN
    case event_move_level_down:
#endif
#ifdef EVENT_BUTTON_FRONT
    case event_button_front_long_press:
#endif
        return view_event_result_handled;
    }
    return view_event_result_not_handled;
}
#endif
view_event_result_t view_others_power_off_event(event_param_t const *param)
{
    switch (param->event)
    {
#ifdef EVENT_NEXT_VIEW
    case event_move_next_view:
#ifdef EVENT_BUTTON_FRONT
    case event_button_front_press:
#endif
        display_show(view_others_camera, DISP_MODE_DOWN_MOVE);
        return view_event_result_handled;
#endif
#ifdef USE_TOUCHPAD
    case BUTTON_EVENT_TP_TAP_LONG:
        motor_start(500);
        system_into_poweroff();
        return view_event_result_handled;
#endif
#ifdef POWER_OFF_MS
#ifdef EVENT_BUTTON_FRONT
    case event_button_front_long_press:
        return view_event_result_handled;
    case BUTTON_EVENT_LONG_PRESS_KEEP:
    {
        if (param->long_press_millisecond >= POWER_OFF_MS)
        {
            LOG("system_into_poweroff %d", param->long_press_millisecond);
            motor_start(500);
            system_into_poweroff();
        }
        return view_event_result_handled;
    }
#endif
#else
#ifdef EVENT_BUTTON_FRONT
    case event_button_front_long_press:
        motor_start(500);
        system_into_poweroff();
        return view_event_result_handled;
#endif
#endif
#ifdef EVENT_LEVEL_DOWN
    case event_move_level_down:
        return view_event_result_handled;
#endif
    }
    return view_event_result_not_handled;
}

view_event_result_t view_others_back_event(event_param_t const *param)
{
    switch (param->event)
    {
#ifdef EVENT_BUTTON_FRONT
    case event_button_front_press:
        display_show(view_others_level_1_begin, DISP_MODE_DOWN_MOVE);
        return view_event_result_handled;
    case event_button_front_long_press:
        display_show(view_others, DISP_MODE_NORMAL);
        return view_event_result_handled;
#endif
    }
    return view_event_result_not_handled;
}

void view_others_display(int32_t view)
{
    Expects(view >= view_others);
    Expects(view < view_others + VIEW_LEVEL_0_SUB_COUNT);
    switch (view)
    {
    case view_others_base:
        view_others_base_display();
        break;
    case view_others_camera:
        view_others_camera_display();
        break;
#ifdef NO_STOPWATCH_UI
#else     		
    case view_others_stopwatch:
        view_others_stopwatch_display();
        break;
#endif		
    case view_others_device_info:
        view_others_device_info_display();
        break;
    case view_others_power_off:
        view_others_power_off_display();
        break;
    case view_others_camera_static:
        view_others_camera_static_display();
        break;
    case view_others_camera_shake:
        view_others_camera_shake_display();
        break;
    case view_others_device_info_detail:
        view_others_device_info_detail_display();
        break;
#if defined(NO_APP_URL_UI)
#else
		#if defined(UMG01_PROJECT)
		#error no app url
		#endif
    case view_others_app_url:
        view_others_app_url_display();
        break;
#endif
    case view_others_back:
        view_others_back_display();
        break;
    }
}

view_event_result_t view_others_event(int32_t view, event_param_t const *param)
{
    Expects(view >= view_others);
    Expects(view < view_others + VIEW_LEVEL_0_SUB_COUNT);
    view_event_result_t result = view_event_result_not_handled;
    switch (view)
    {
#ifdef NO_STOPWATCH_UI
#else     
    case view_others_stopwatch:
        result = view_others_stopwatch_event(param);
        break;
#endif			
    case view_others_camera:
        result = view_others_camera_event(param);
        break;
    case view_others_camera_static:
        result = view_others_camera_static_event(param);
        break;
    case view_others_camera_shake:
        result = view_others_camera_shake_event(param);
        break;
    case view_others_device_info_detail:
        result = view_others_device_info_detail_event(param);
        break;
#if defined(NO_APP_URL_UI)
#else
    case view_others_app_url:
        result = view_others_app_url_event(param);
        break;
#endif
    case view_others_power_off:
        result = view_others_power_off_event(param);
        break;
    case view_others_back:
        result = view_others_back_event(param);
        break;
    }
    if (result == view_event_result_handled)
    {
        return result;
    }
    return view_event_result_not_handled;
}
